package lab03.test01;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Map;

public class Test01 {
    public static void main(String[] args) {


        String path="D:\\java实验\\hello.txt";
        RandomAccessFile file=null;
        Map<String, Integer> map = new HashMap<String, Integer>();

        try {
            try {
                file=new RandomAccessFile(path,"r");
                String line=null;
                while((line=file.readLine())!=null){
                    System.out.println(line);
                    if (map.get(line)==null){
                        map.put(line,1);
                    }else{
                        int value=map.get(line);
                        value=value+1;
                        map.put(line ,value);
                    }
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        finally {
            try {
                file.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
